package com.ctshk.rpc.finance.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ctshk.rpc.finance.dto.special.SpecialCollectionListDTO;
import com.ctshk.rpc.finance.entity.FinanceSpecialCollection;
import com.ctshk.rpc.finance.req.special.SpecialCollectionListReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 财务特殊收款 Mapper 接口
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-05
 */
public interface FinanceSpecialCollectionMapper extends BaseMapper<FinanceSpecialCollection> {

    /**
     * 列表
     * @param iPage
     * @param req
     * @return
     */
    @Select("<script>SELECT a.*\n" +
            "FROM t_finance_special_collection a\n" +
            "WHERE a.is_deleted = 0\n" +
            "<if test=\"req.payer != null\">AND a.payer LIKE CONCAT('%',#{req.payer},'%')</if> \n" +
            "<if test=\"req.collectionNumber != null\">AND a.collection_number LIKE CONCAT('%',#{req.collectionNumber},'%')</if> \n" +
            "<if test=\"req.currencyId != null\">AND a.currency_id = #{req.currencyId}</if> \n" +
            "<if test=\"req.collectionType != null\">AND a.collection_type = #{req.collectionType}</if> \n" +
            "<if test=\"req.createlTimeBegin != null and req.createlTimeEnd != null\">AND a.gmt_create BETWEEN #{req.createlTimeBegin} AND #{req.createlTimeEnd}</if> \n" +
            "<if test=\"req.createId != null\">AND a.create_id = #{req.createId}</if> \n" +
            "ORDER BY a.gmt_create DESC</script>")
    Page<SpecialCollectionListDTO> queryListByCondition(@Param("iPage") Page<SpecialCollectionListDTO> iPage, @Param("req") SpecialCollectionListReq req);
}
